<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>输血不良事件上报表</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <script src="../layui/layui.js"></script>
</head>
<body>
<form class="layui-form" lay-filter="FormLoad">
    <table border="1px" width="100%" cellpadding="0">
        <tr >
            <td colspan="8" style="text-align: center; height: 50px"> <span style=" font-size: 20px">输血不良反应回报单</span> </td>
        </tr>
        <tr>
            <div class="layui-form-item">
                <td colspan="2">
                    时间：
                </td>
                <td colspan="6">
                    <input type="text" name="report_date" id="report_date" placeholder="" class="layui-input">
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">
                <td colspan="1">
                    受血患者姓名：
                </td>
                <td colspan="1">
                    <input type="text" name="patient_name" placeholder="" class="layui-input">
                </td>
                <td colspan="1">
                    性别
                </td>
                <td colspan="1">
                    <select name="patient_sex" lay-verify="required">
                        <option value=""></option>
                        <option value="男">男</option>
                        <option value="女">女</option>
                    </select>
                </td>

                <td colspan="1">
                    年龄
                </td>
                <td colspan="1">
                    <input type="text" name="patient_age" placeholder="" class="layui-input">
                </td>
                <td colspan="1">
                    血型
                </td>
                <td colspan="1">
                    <input type="text" name="patient_blood_type" placeholder="" class="layui-input">
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">

                <td>
                    住院门诊号：
                </td>
                <td colspan="1">
                    <input type="text" name="patient_num" placeholder="" class="layui-input">
                </td>
                <td colspan="1">
                    科别
                </td>
                <td colspan="2">
                    <input type="text" name="reporter_department" placeholder="" class="layui-input">
                </td>
                <td colspan="1">
                    床号
                </td>
                <td colspan="2">
                    <input type="text" name="patient_bed_num" placeholder="" class="layui-input">
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">

                <td>
                    输血史
                </td>
                <td colspan="1">
                    <input type="radio" name="patient_transfusion_history" value="有" title="有">
                    <input type="radio" name="patient_transfusion_history" value="无" title="无" >
                </td>
                <td colspan="1">
                    妊娠史
                </td>
                <td colspan="2">
                    <input type="radio" name="patient_pregnancy_history" value="孕" title="孕">
                    <input type="radio" name="patient_pregnancy_history" value="产" title="产">
                    <input type="radio" name="patient_pregnancy_history" value="无" title="无">
                </td>
                <td colspan="3"></td>
            </div>
        </tr>
        <td colspan="8" style="text-align: center; height: 30px"> <span style=" font-size: 12px">临床诊断</span> </td>
        <tr>
            <div class="layui-form-item">

                <td colspan="2">
                    输血时患者是否处于全麻状态：
                </td>
                <td colspan="2">
                    <input type="radio" name="patient_transfusion_status" value="是" title="是">
                    <input type="radio" name="patient_transfusion_status" value="否" title="否" >
                </td>
                <td colspan="2">
                    输血不良反应:
                </td>
                <td colspan="2">
                    <input type="radio" name="patient_transfusion_bad_event" value="有" title="有">
                    <input type="radio" name="patient_transfusion_bad_event" value="无" title="无" >
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">
                <td rowspan="2">
                    输入血液：
                </td>

                <td colspan="1">
                    血型：
                </td>
                <td colspan="2">
                    <input type="text" name="patient_transfusion_blood_type" placeholder="" class="layui-input">
                </td>
                <td colspan="2"> 血肿：</td>
                <td colspan="2">
                    <input type="text" name="patient_transfusion_blood_kind" placeholder="" class="layui-input">
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">

                <td colspan="1">
                    输入量：
                </td>
                <td colspan="2">
                    <input type="text" name="patient_transfusion_blood_amount" placeholder="" class="layui-input">
                </td>
                <td colspan="2"> 血袋信息码：</td>
                <td colspan="2">
                    <input type="text" name="patient_transfusion_blood_num" placeholder="" class="layui-input">
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">
                <td colspan="1">
                    献血者与受害者的关系：
                </td>
                <td colspan="7">
                    <input type="radio" name="volunteer_relation_patient" value="一级亲属关系" title="一级亲属关系">
                    <input type="radio" name="volunteer_relation_patient" value="二级亲属关系" title="二级亲属关系" >
                    <input type="radio" name="volunteer_relation_patient" value="无亲属关系" title="无亲属关系" >
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">
                <td rowspan="4">
                    输血不良反应情况
                </td>
                <td>
                    发生时间：
                </td>
                <td colspan="3">
                    <input type="radio" name="patient_transfusion_happen_time" value="输血前" title="输血前">
                    <input type="radio" name="patient_transfusion_happen_time" value="输血后" title="输血后" >
                </td>
                <td colspan="1">
                    转归：
                </td>
                <td colspan="2">
                    <input type="radio" name="patient_transfusion_class" value="治愈" title="治愈">
                    <input type="radio" name="patient_transfusion_class" value="死亡" title="死亡" >
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">

                <td>
                    症状与体征：
                </td>
                <td colspan="6">
                    <input type="checkbox" name="patient_transfusion_symptom" title="发热" value="发热" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="发组" value="发组" lay-skin="primary">
                    <input type="checkbox" name="patient_transfusion_symptom" title="腰背痛" value="腰背痛" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="呼吸困难" value="呼吸困难" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="两肺布满湿性落音" value="两肺布满湿性落音" lay-skin="primary">
                    <input type="checkbox" name="patient_transfusion_symptom" title="黄痘" value="黄痘" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="寒战" value="寒战" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="荨麻疹" value="荨麻疹" lay-skin="primary">
                    <input type="checkbox" name="patient_transfusion_symptom" title="酱油性尿" value="酱油性尿" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="咳大量血性泡沫样痰" value="咳大量血性泡沫样痰" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="休克" value="休克" lay-skin="primary">
                    <input type="checkbox" name="patient_transfusion_symptom" title="皮肤充血" value="皮肤充血" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="劲静脉怒张" value="劲静脉怒张" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="伤口渗血不止" value="伤口渗血不止" lay-skin="primary" >
                    <input type="checkbox" name="patient_transfusion_symptom" title="其他" value="其他" lay-skin="primary" >
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">
                <td colspan="1">
                    临床科室处理措施
                </td>
                <td colspan="6">
                    <textarea name="clinical_dept_deal" style="height: 50px" required lay-verify="required" placeholder="请输入" class="layui-textarea"></textarea>
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">
                <td colspan="1">
                    诊断：
                </td>
                <td colspan="6">
                    <input type="radio" name="bad_event_diagnose" value="发热反应" title="发热反应">
                    <input type="radio" name="bad_event_diagnose" value="过敏反应" title="过敏反应" >
                    <input type="radio" name="bad_event_diagnose" value="急性溶血反应" title="急性溶血反应" >
                    <input type="radio" name="bad_event_diagnose" value="其他" title="其他" >
                </td>
            </div>
        </tr>
        <tr>
            <div class="layui-form-item">
                <td colspan="1">
                    签名
                </td>
                <td colspan="1">
                    护士
                </td>
                <td colspan="2">
                    <input type="text" name="nurse_sign" placeholder="" class="layui-input">
                </td>
                <td colspan="1">
                    经治医师：
                </td>
                <td colspan="1">
                    <input type="text" name="treat_doctor_sign" placeholder="" class="layui-input">
                </td>
                <td colspan="1">
                    临床科主任：
                </td>
                <td colspan="1">
                    <input type="text" name="clinical_dept_header_sign" placeholder="" class="layui-input">
                </td>
            </div>
        </tr>
        <tr>
            <td colspan="3">
                输血科主任或负责人：
            </td>
            <td colspan="5">
                <input type="text" name="transfusion_dept_header_sign" placeholder="" class="layui-input">
            </td>
        </tr>
        <tr>        <td colspan="8">
            <span>备注：</span>
            <ol>
                <li>①.病症诊疗问题：。。。。。。。。。。。</li>
                <li>②.意外事件：包括。。。。。。。。。。。。</li>

            </ol>
        </td>       </tr>

    </table>
    <div class="layui-form-item">
        <div class="layui-input-block" style="text-align: center; margin-top: 50px">
            <button class="layui-btn" lay-submit lay-filter="YiLiaoqx">立即提交</button>
            <button class="layui-btn" lay-submit lay-filter="save">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script>

    layui.use(['laydate','jquery','form','layedit','layer','table','laytpl'], function() {
        let $ = layui.jquery;
        let form = layui.form;
        let laydate = layui.laydate;
        var layer = layui.layer;
        var router = layui.router();
        laydate.render({
            elem: '#report_date' //指定元素
            , type: 'date'
        });


        form.render();
        // 获取地址的中的值
        let user_code=decodeURIComponent(router.search.user_code);
        let user_name=decodeURIComponent(router.search.user_name);
        let dept_code=decodeURIComponent(router.search.dept_code);
        let dept_name=decodeURIComponent(router.search.dept_name);
        // layui data 保存数据
        if( user_code=="undefined"){
            console.log(layui.data('user').userinfo.user_name)
        } else{
            console.log(user_code);
            console.log("地址有值")
            layui.data('user', {
                key: 'userinfo',
                value:
                    {
                        user_name: user_name,
                        user_code: user_code,
                        dept_code:dept_code,
                        dept_name:dept_name
                    }
            });
            console.log(layui.data('user').userinfo.user_name)
        }
        //渲染 上报人和上报人单位
        form.val("FormLoad",{
            "reporter": layui.data('user').userinfo.user_name.replace(/\"/g, "") ,
            "reporter_department":layui.data('user').userinfo.dept_name.replace(/\"/g, "")
        })

        // submit 提交事件监听
        form.on('submit(YiLiaoqx)', function(data) {
            var arr_box = [];
            var str_checked="";
            $('input[type=checkbox]:checked').each(function(index) {
                arr_box.push($(this).val());
                str_checked+=arr_box[index];
                str_checked+=",";
            });
            layer.confirm('确定提交吗？', {
                btn: ['确认', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: '/event/event_insert',
                    type: "POST",
                    data:{
                        "reporter_code":layui.data('user').userinfo.user_code,
                        "reporter_name":layui.data('user').userinfo.user_name,
                        "dept_code":layui.data('user').userinfo.dept_code,
                        "dept_name":layui.data('user').userinfo.dept_name,
                        "event_code":7,
                        "report_date":data.field.report_date,
                        "patient_name":data.field.patient_name,
                        "patient_sex":data.field.patient_sex,
                        "patient_age":data.field.patient_age,
                        "patient_blood_type":data.field.patient_blood_type,
                        "patient_num":data.field.patient_num,
                        "reporter_department":data.field.reporter_department,
                        "patient_bed_num":data.field.patient_bed_num,
                        "patient_transfusion_history":data.field.patient_transfusion_history,
                        "patient_transfusion_status":data.field.patient_transfusion_status,
                        "patient_transfusion_bad_event":data.field.patient_transfusion_bad_event,
                        "patient_transfusion_blood_type":data.field.patient_transfusion_blood_type,
                        "patient_transfusion_blood_kind":data.field.patient_transfusion_blood_kind,
                        "patient_transfusion_blood_amount":data.field.patient_transfusion_blood_amount,
                        "patient_transfusion_blood_num":data.field.patient_transfusion_blood_num,
                        "volunteer_relation_patient":data.field.volunteer_relation_patient,
                        "patient_pregnancy_history":data.field.patient_pregnancy_history,
                        "patient_transfusion_happen_time":data.field.patient_transfusion_happen_time,
                        "patient_transfusion_class":data.field.patient_transfusion_class,
                        "patient_transfusion_symptom":str_checked,
                        "clinical_dept_deal":data.field.clinical_dept_deal,
                        "bad_event_diagnose":data.field.bad_event_diagnose,
                        "nurse_sign":data.field.nurse_sign,
                        "treat_doctor_sign":data.field.treat_doctor_sign,
                        "clinical_dept_header_sign":data.field.clinical_dept_header_sign,
                        "transfusion_dept_header_sign":data.field.transfusion_dept_header_sign,
                        "status":2 //递交
                    },
                    success:function () {
                        layer.msg("保存成功");
                        form.val("FormLoad",{
                            "report_date":null,
                            "patient_name":null,
                            "patient_sex":null,
                            "patient_age":null,
                            "patient_blood_type":null,
                            "patient_num":null,
                            "reporter_department":null,
                            "patient_bed_num":null,
                            "patient_transfusion_history":null,
                            "patient_transfusion_status":null,
                            "patient_transfusion_bad_event":null,
                            "patient_transfusion_blood_type":null,
                            "patient_transfusion_blood_kind":null,
                            "patient_transfusion_blood_amount":null,
                            "patient_transfusion_blood_num":null,
                            "volunteer_relation_patient":null,
                            "patient_pregnancy_history":null,
                            "patient_transfusion_happen_time":null,
                            "patient_transfusion_class":null,
                            "patient_transfusion_symptom":null,
                            "clinical_dept_deal":null,
                            "bad_event_diagnose":null,
                            "nurse_sign":null,
                            "treat_doctor_sign":null,
                            "clinical_dept_header_sign":null,
                            "transfusion_dept_header_sign":null,
                        })
                        form.render();
                    },
                })

            }, function () {
            });
            console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //save 保存事件监听
        form.on('submit(save)', function(data) {
            var arr_box = [];
            var str_checked="";
            $('input[type=checkbox]:checked').each(function(index) {
                arr_box.push($(this).val());
                str_checked+=arr_box[index];
                str_checked+=",";
            });
            $.ajax({
                url: '/event/event_insert',
                type: "POST",
                data:{
                    "reporter_code":layui.data('user').userinfo.user_code,
                    "reporter_name":layui.data('user').userinfo.user_name,
                    "dept_code":layui.data('user').userinfo.dept_code,
                    "dept_name":layui.data('user').userinfo.dept_name,
                    "event_code":7,
                    "report_date":data.field.report_date,
                    "patient_name":data.field.patient_name,
                    "patient_sex":data.field.patient_sex,
                    "patient_age":data.field.patient_age,
                    "patient_blood_type":data.field.patient_blood_type,
                    "patient_num":data.field.patient_num,
                    "reporter_department":data.field.reporter_department,
                    "patient_bed_num":data.field.patient_bed_num,
                    "patient_transfusion_history":data.field.patient_transfusion_history,
                    "patient_transfusion_status":data.field.patient_transfusion_status,
                    "patient_transfusion_bad_event":data.field.patient_transfusion_bad_event,
                    "patient_transfusion_blood_type":data.field.patient_transfusion_blood_type,
                    "patient_transfusion_blood_kind":data.field.patient_transfusion_blood_kind,
                    "patient_transfusion_blood_amount":data.field.patient_transfusion_blood_amount,
                    "patient_transfusion_blood_num":data.field.patient_transfusion_blood_num,
                    "volunteer_relation_patient":data.field.volunteer_relation_patient,
                    "patient_pregnancy_history":data.field.patient_pregnancy_history,
                    "patient_transfusion_happen_time":data.field.patient_transfusion_happen_time,
                    "patient_transfusion_class":data.field.patient_transfusion_class,
                    "patient_transfusion_symptom":str_checked,
                    "clinical_dept_deal":data.field.clinical_dept_deal,
                    "bad_event_diagnose":data.field.bad_event_diagnose,
                    "nurse_sign":data.field.nurse_sign,
                    "treat_doctor_sign":data.field.treat_doctor_sign,
                    "clinical_dept_header_sign":data.field.clinical_dept_header_sign,
                    "transfusion_dept_header_sign":data.field.transfusion_dept_header_sign,
                    "status": 1//1表示保存，可修改
                },
                success:function () {
                    layer.msg("保存成功");
                    form.val("FormLoad",{
                        "report_date":null,
                        "patient_name":null,
                        "patient_sex":null,
                        "patient_age":null,
                        "patient_blood_type":null,
                        "patient_num":null,
                        "reporter_department":null,
                        "patient_bed_num":null,
                        "patient_transfusion_history":null,
                        "patient_transfusion_status":null,
                        "patient_transfusion_bad_event":null,
                        "patient_transfusion_blood_type":null,
                        "patient_transfusion_blood_kind":null,
                        "patient_transfusion_blood_amount":null,
                        "patient_transfusion_blood_num":null,
                        "volunteer_relation_patient":null,
                        "patient_pregnancy_history":null,
                        "patient_transfusion_happen_time":null,
                        "patient_transfusion_class":null,
                        "patient_transfusion_symptom":null,
                        "clinical_dept_deal":null,
                        "bad_event_diagnose":null,
                        "nurse_sign":null,
                        "treat_doctor_sign":null,
                        "clinical_dept_header_sign":null,
                        "transfusion_dept_header_sign":null,
                    })
                    form.render();
                },
            });
            console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>

</html>